package com.wbk.lotteryadmin.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

@EnableWebMvc
@Configuration
public class MyConfig implements WebMvcConfigurer {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/js/**").addResourceLocations("classpath:/static/js/");
        registry.addResourceHandler("/css/**").addResourceLocations("classpath:/static/css/");
        registry.addResourceHandler("/assets/**").addResourceLocations("classpath:/static/assets/");
        registry.addResourceHandler("/scripts/**").addResourceLocations("classpath:/static/scripts/");
        registry.addResourceHandler("/src/**").addResourceLocations("classpath:/static/src/");
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/login").setViewName("/login");
        registry.addViewController("/index").setViewName("/index");

        registry.addViewController("/users").setViewName("/admin/users");
        registry.addViewController("/stores").setViewName("/admin/stores");
        registry.addViewController("/stores_audit").setViewName("/admin/stores_audit");
        registry.addViewController("/lotterys").setViewName("/admin/lotterys");
        registry.addViewController("/lotterys_audit").setViewName("/admin/lotterys_audit");
    }
}
